import {
  BaseEntity,
  Column,
  CreateDateColumn,
  DeleteDateColumn,
  Entity,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Warehouse } from './warehouse.entity';
import { Box } from './box.entity';

@Entity()
export class Outboundplan extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    comment: '数据',
    nullable: true,
    unique: false,
    default: null,
    type: 'text',
  })
  data: string;

  @Column({
    comment: '运单号',
    nullable: true,
    unique: false,
    default: null,
    type: 'varchar',
  })
  mercadoBoxNumber: string;

  @Column({
    comment: '总箱数',
    nullable: true,
    unique: false,
    default: 0,
    type: 'int',
  })
  totalBoxNumber: number;

  @Column({
    comment: '总数量',
    nullable: true,
    unique: false,
    default: 0,
    type: 'int',
  })
  totalNumber: number;

  @Column({
    comment: '状态',
    nullable: true,
    unique: false,
    default: null,
    type: 'int',
  })
  status: number;

  @Column({
    comment: '操作人Id',
    nullable: true,
    unique: false,
    default: null,
    type: 'int',
  })
  adminId: number;

  @ManyToOne(() => Warehouse, (warehouse) => warehouse.outboundplans)
  warehouse: Warehouse;

  @OneToMany(() => Box, (box) => box.outboundplan)
  boxs: Box[];

  @CreateDateColumn()
  createTime: Date;

  @UpdateDateColumn()
  updateTime: Date;

  @DeleteDateColumn({ nullable: true })
  deleteTime: Date;
}
